var parentData, parentActive;
var dateFormatStr = 'yyyy-MM-dd HH:mm:ss';

layui.use(['form', 'table', 'layer', 'laydate'], function () {
	var form = layui.form,
		layer = layui.layer,
		table = layui.table,
		laydate = layui.laydate,
		$ = layui.$;


	window.active = {
		// 编辑发货
		select:async (data) => {
			formdata = form.val("dataform");
			formdata.order_id = parentData.order_id,
			formdata.wuliuc_id = data.id,
			formdata.no=$('#no').val(),
			formdata.tel=$('#tel').val(),
			formdata.name=formdata.name,
			formdata.address=formdata.address
			delete formdata.id;
			// await ajaxAsyncNoTip('order/upd_send',{order_id,wuliuc_id,no,tel,name,address},'POST')
		}
	};

	// 物流公司表格渲染
	table.render({
		elem: '#tableList', //需要显示数据表格的table标签
		url: baseUrl('order/logistics') ,//请求地址
		method: 'GET' ,//请求方式
		cellMinWidth: 150,
		height:375,
		cols: [[
			{field:'name', title: '物流公司名称', } ,
			{width: 220, fixed: 'right', title:'操作',templet: '#tableListBar'}
		]],
		page: true,//开启分页
		limits: ['30', '50', '100'],//分页每页显示数据条数（页面选择）
	});

	//操作
	$('.layui-btn').on('click', function () {
		var type = $(this).data('type');
		active[type] ? active[type].call(this) : '';
	});
	//表格头部按钮操作
	table.on('toolbar(tableList)', function (obj) {
		var type = obj.event;
		active[type] ? active[type].call(this, obj.data) : '';
	});
	//表格按钮操作
	table.on('tool(tableList)', function (obj) {
		var type = obj.event;
		active[type] ? active[type].call(this, obj.data) : '';
	});



		//延时初始化，确保数据已经塞进来了
		setTimeout(() => {
			let infoData=parentData.wuliu_id
			//执行一个laydate实例
			laydate.render({
				elem: '#dt', //指定元素
				type: 'datetime',
				trigger: 'click',
				min: js.format_datetime(new Date(), dateFormatStr),
				value: js.format_datetime(infoData && infoData.dt || new Date(), dateFormatStr),
			});
			if (!infoData) return;
			//初始化数据
			form.val("dataform", JSON.parse(JSON.stringify(infoData)));
		}, 200);

	form.verify({});
	form.on("submit(save)", element => {
		popSubmitDial('order/upd_send',formdata)
		return false;
	});
	
});